#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<stdint.h>
#include<stdlib.h>

struct Eight
{
    Eight(){
        m_visit = new unsigned char[size/8+1];
        path = new std::vector<char>[size];
    }
    ~Eight(){
        delete []m_visit;
        delete []path;
    }
    inline bool visit(int index)
    {
        int i_bytes = index/8;
        int i_bits = index%8;
        unsigned char flag = (1<<i_bits);
        if((m_visit[i_bytes]&flag)==flag)
            return true;
        return false;
    }
    inline void set_visit(int index)
    {
        int i_bytes = index/8;
        int i_bits = index%8;
        unsigned char flag = (1<<i_bits);
        m_visit[i_bytes]= (m_visit[i_bytes]|flag);
    }
    const int factorial[9]={1, 1, 2, 6, 24, 120, 720, 5040, 40320};
    const int size = 362880;
    unsigned char *m_visit;
    std::vector<char> *path;
    /**
     * @brief canto.compute index by sequence.
     * @param s
     * @return index
     */
    inline int canto(const char *s)
    {
        int index = 0;
        for(int i = 0; i < 9; i++)
        {
            int count = 0;
            for(int j=i+1; j < 9; j++)
            {
                if(s[j]<s[i])
                    count++;
            }
            index += factorial[8-i]*count;
        }
        return index;
    }
    /**
     * @brief rcanto reverse index. compute sequence by index.
     * @param index
     * @param s
     */
    inline void rcanto(int index, char *s)
    {
        bool vt[9]={0};
        for(int i = 0; i < 9; i++){
            int temp = index/factorial[8-i];
            int j;
            for(j = 0; j < 9; j++)
            {
                if(!vt[j])
                {
                    if(temp>=1)temp--;
                    else break;
                }
            }
            index%=factorial[8-i];
            s[i]=j+'0';
            vt[j]=true;
        }
    }
    inline bool move(char orientation, char *s)
    {
        int dx,dy,ox,oy;
        switch (orientation) {
        case 'u':
            dy=-1;dx=0;break;
        case 'd':
            dy=1;dx=0;break;
        case 'l':
            dy=0;dx=-1;break;
        default:
            dy=0;dx=1;
        }
        for(int i = 0; i < 9; i++)
        {
            if(s[i]=='0')
            {
                ox=i%3;oy=i/3;
                dx+=ox;
                dy+=oy;
                if(dx<0||dx>2||dy<0||dy>2)
                    return false;
                std::swap(s[i], s[dy*3+dx]);
                return true;
            }
        }
        return false;
    }
    static void display(std::vector<char> p)
    {
        for(auto ite = p.rbegin(); ite != p.rend(); ite++)
            std::cout<<*ite;
    }
    void bfs()
    {
        std::queue<int> path1;
        char start[9]={'1','2','3','4','5','6','7','8','0'};
        int index = canto(start);
        set_visit(index);
        path1.push(index);
        while (!path1.empty()) {
            std::queue<int> path2;
            while (!path1.empty()) {

                int oindex = path1.front();
                char tg[9],tgu[9],tgd[9],tgl[9],tgr[9];
                rcanto(oindex, tg);
                for(int i = 0; i < 9; i++)
                {
                    tgu[i]=tgd[i]=tgl[i]=tgr[i]=tg[i];
                }
                path1.pop();
                if(move('u', tgu))
                {
                    int index = canto(tgu);
                    if(!visit(index)){
                        set_visit(index);
                        path[index]=path[oindex];
                        path[index].push_back('d');
                        path2.push(index);
                    }
                }
                if(move('d',tgd))
                {
                    int index = canto(tgd);
                    if(!visit(index)){
                        set_visit(index);
                        path[index]=path[oindex];
                        path[index].push_back('u');
                        path2.push(index);
                    }
                }
                if(move('l',tgl))
                {
                    int index = canto(tgl);
                    if(!visit(index)){
                        set_visit(index);
                        path[index]=path[oindex];
                        path[index].push_back('r');
                        path2.push(index);
                    }
                }
                if(move('r',tgr))
                {
                    int index = canto(tgr);
                    if(!visit(index)){
                        set_visit(index);
                        path[index]=path[oindex];
                        path[index].push_back('l');
                        path2.push(index);
                    }
                }

            }
            path1=path2;
        }
    }
};

int main() {
    Eight e;
    e.bfs();

    char a[9];
    while (std::cin>>a[0]) {
        a[0]=a[0]=='x'?'0':a[0];
        for(int i = 1; i < 9; i++)
        {
            std::cin>>a[i];
            a[i]=a[i]=='x'?'0':a[i];
        }
        int index = e.canto(a);
        bool correct = true;
        for(int i = 0; i < 9; i++)
        {
            if((a[i]-'0')!=(i+1)%9)
                 correct=false;
        }
        if(correct){std::cout<<std::endl;continue;}
        if(e.path[index].size()==0)
            std::cout<<"unsolvable"<<std::endl;
        else
        {
            e.display(e.path[index]);
            std::cout<<std::endl;
        }
    }
    return 0;
}
